/**全局配置 Config */
import L from "leaflet";
import 'leaflet.pm';
import 'leaflet.pm/dist/leaflet.pm.css';
import ScalarLayer from "../layer/ScalarLayer.js";
import ParticleLayer from "../layer/ParticleLayer.js";
// import TileLayerCALCSHA1 from "@a/js/L.tileLayer.CALCSHA1.js";
import windFeatherLayer from "../layer/windFeatherLayer.js";
let Config = {
  ajaxTimeout: 6000,
  aniTime: 300, //动画时间

  AllLayers: null /**地图图层集合 */,
  ToolLayers: null /**工具图层集合 */,
  curData: {} /**当前时刻缓存数据 */,
  ImgData: {} /**数据缓存 */,
  ImgDate: "" /** 当前时间 */,
  TimeSlider: null /**时间滑条 */,
  typhoonYears: null,
  typhoonDatas: {},
  showLoading: () => { },
  hideLoading: () => { },
  area: {} /** 当前区域信息 */,

  mapObj: {
    map: null /**地图对象 */,
    mapCenter: [] /**地图中心 */,
    // mapCenterGroup: {
    //   wenzhou: [27.7, 121.1],
    //   taizhou: [28.5, 121.76]
    // },
    // cityCenter: {
    //   wenzhou: [27.9911, 120.6993],
    //   taizhou: [28.6563, 121.4212]
    // },
    maxBound: L.latLngBounds(
      L.latLng(80, -3600),
      L.latLng(-80, 3600)
    ) /**地图范围 */,
    minZ: 3,
    maxZ: 14,
    zoom: 9,
    crs: L.CRS.EPSG3857,
    jxhzoom: 5,
    jxhzoomF: 5,
  },

  time: {
    /**时间配置 */ startTimeObj: "yyyy-MM-dd HH:00:00",
    endTimeObj: "yyyy-MM-dd HH:00:00",
    DateObj: "yyyy-MM-dd HH:00:00",
    dataTime: "2021050100",
    dataTimeUTC: "2021050100",
  },

  isShow: {
    isOnQuery: false /* 是否开启单点查询 */,
    allowParticle: false,
    wave: false,
    rwave: false,
    rtpwave: false,
    curRtpwave: "" /** 存储台风浪编号 [空，编号] */,
    waveType: "rwave",
    wind: "rwind",
    awind: "arwind",
    rcurrent: false,
    currentType: "rcurrent",
    surge: false,
    surgeType: "",
    curSurge: "" /** 存储风暴潮编号  [类型（最大、计算、潮位），编号，路径] */,
    tyInfoBox: false,
    tyInfoBoxshow: false,
    onSS: false,
    detail: {},
  },

  layerIndex: {
    baseMapIndex: 1,
    waveIndex: 10,
    waveDirParticle: 11,
    rwaveIndex: 12,
    rwaveDirParticle: 500,
    rtpwaveIndex: 14,
    rtpwaveDirParticle: 500,
    currentParticle: 16,
    rcurrentParticle: 17,
    tide: 18,
    surge: 18,
    windIndex: 22,
    windParticle: 24 /* 风场粒子 */,
    windFeatherIndex: 26 /* 风羽图 */,
    noSeaIndex: 20, //掩膜
    boundaryLine: 30, //海风边界矢量
    placeNameNote: 32,
    //overlayPane中canvas默认为100
  },

  rasterHeader: {
    global: {
      // startLon: 0.0,
      // endLon: 360.0,
      // startLat: 90,
      // endLat: -90,
      // scale: 0.25,
      // uscale: 0.25,
      // vscale: 0.25,
      // scaleStr: "-1.0"
      startLon: 119.6354,
      endLon: 124,
      startLat: 30.88738,
      endLat: 25.8696,
      uscale: 0.0044,
      vscale: 0.0052,
      pixel: 1000,
    },
    wave: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    rcurrent: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      scale: 0.08315,
      pixel: 475,
    },
    rtide: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    arwind: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    rwave: {
      startLon: 119.6,
      endLon: 124,
      startLat: 31,
      endLat: 25.8,
      uscale: 0.0044,
      vscale: 0.0052,
      pixel: 1000,
    },
    rtpwave: {
      startLon: 114,
      endLon: 133.8,
      startLat: 41,
      endLat: 16.2,
      uscale: 0.0198,
      vscale: 0.0248,
      pixel: 1000,
    },
    rwind: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    rwindengry: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    rgrade: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
    reffect: {
      startLon: 99.0416,
      endLon: 137.04,
      startLat: 41.0416,
      endLat: 1.541666627,
      uscale: 0.08315,
      vscale: 0.08315,
      pixel: 475,
    },
  },

  scalarColor: {
    wind: [
      {
        value: 0,
        color: "rgb(81,88,169)",
      },
      {
        value: 2,
        color: "rgb(68,118,179)",
      },
      {
        value: 4,
        color: "rgb(68,143,166)",
      },
      {
        value: 6,
        color: "rgb(72,165,138)",
      },
      {
        value: 8,
        color: "rgb(73,185,87)",
      },
      {
        value: 10,
        color: "rgb(137,200,70)",
      },
      {
        value: 12,
        color: "rgb(174,205,67)",
      },
      {
        value: 14,
        color: "rgb(201,206,62)",
      },
      {
        value: 16,
        color: "rgb(211,195,60)",
      },
      {
        value: 18,
        color: "rgb(213,163,64)",
      },
      {
        value: 20,
        color: "rgb(212,150,67)",
      },
      {
        value: 22,
        color: "rgb(212,125,72)",
      },
      {
        value: 24,
        color: "rgb(204,95,90)",
      },
      {
        value: 26,
        color: "rgb(197,76,117)",
      },
      {
        value: 28,
        color: "rgb(198,79,147)",
      },
      {
        value: 30,
        color: "rgb(223,108,201)",
      },
      {
        value: 32,
        color: "rgb(225,117,236)",
      },
      {
        value: 34,
        color: "rgb(199,112,253)",
      },
      {
        value: 36.9,
        color: "rgb(155,100,254)",
      },
    ],
    wind_speed: [
      {
        value: 0,
        color: "rgb(81,88,169)",
      },
      {
        value: 2,
        color: "rgb(68,118,179)",
      },
      {
        value: 4,
        color: "rgb(68,143,166)",
      },
      {
        value: 6,
        color: "rgb(72,165,138)",
      },
      {
        value: 8,
        color: "rgb(73,185,87)",
      },
      {
        value: 10,
        color: "rgb(137,200,70)",
      },
      {
        value: 12,
        color: "rgb(174,205,67)",
      },
      {
        value: 14,
        color: "rgb(201,206,62)",
      },
      {
        value: 16,
        color: "rgb(211,195,60)",
      },
      {
        value: 18,
        color: "rgb(213,163,64)",
      },
      {
        value: 20,
        color: "rgb(212,150,67)",
      },
      {
        value: 22,
        color: "rgb(212,125,72)",
      },
      {
        value: 24,
        color: "rgb(204,95,90)",
      },
      {
        value: 26,
        color: "rgb(197,76,117)",
      },
      {
        value: 28,
        color: "rgb(198,79,147)",
      },
      {
        value: 30,
        color: "rgb(223,108,201)",
      },
      {
        value: 32,
        color: "rgb(225,117,236)",
      },
      {
        value: 34,
        color: "rgb(199,112,253)",
      },
      {
        value: 36.9,
        color: "rgb(155,100,254)",
      },
      {
        value: 38,
        color: "rgb(79,175,252)",
      },
      {
        value: 40,
        color: "rgb(65,189,251)",
      },
      {
        value: 42,
        color: "rgb(55,199,251)",
      },
      {
        value: 44,
        color: "rgb(55,199,251)",
      },
      {
        value: 46,
        color: "rgb(55,199,251)",
      },
      {
        value: 48,
        color: "rgb(55,199,251)",
      },
      {
        value: 50,
        color: "rgb(55,199,251)",
      },
    ],
    awind: [
      {
        value: 0,
        color: "rgb(255,255,255)",
      },
      {
        value: 2,
        color: "rgb(193,231,249)",
      },
      {
        value: 4,
        color: "rgb(107,174,220)",
      },
      {
        value: 6,
        color: "rgb(72,160,139)",
      },
      {
        value: 6,
        color: "rgb(103,190,74)",
      },
      {
        value: 10,
        color: "rgb(241,229,91)",
      },
      {
        value: 12,
        color: "rgb(249,198,79)",
      },
      {
        value: 14,
        color: "rgb(245,109,42)",
      },
      {
        value: 16,
        color: "rgb(228,67,40)",
      },
      {
        value: 18,
        color: "rgb(188,39,65)",
      },
      {
        value: 20,
        color: "rgb(162,48,93)",
      },
    ],
    windEngry: [
      {
        value: 0,
        color: "rgb(255,255,255)",
      },
      {
        value: 100,
        color: "rgb(193,231,249)",
      },
      {
        value: 200,
        color: "rgb(107,174,220)",
      },
      {
        value: 300,
        color: "rgb(72,160,139)",
      },
      {
        value: 400,
        color: "rgb(103,190,74)",
      },
      {
        value: 500,
        color: "rgb(241,229,91)",
      },
      {
        value: 600,
        color: "rgb(249,198,79)",
      },
      {
        value: 700,
        color: "rgb(245,109,42)",
      },
      {
        value: 800,
        color: "rgb(228,67,40)",
      },
      {
        value: 900,
        color: "rgb(188,39,65)",
      },
      {
        value: 1000,
        color: "rgb(162,48,93)",
      },
      // {
      //   "value": 21,
      //   "color": "rgb(255, 206, 53)"
      // }, {
      //   "value": 24,
      //   "color": "rgb(255, 164, 62)"
      // }, {
      //   "value": 27,
      //   "color": "rgb(233, 123, 72)"
      // }, {
      //   "value": 30,
      //   "color": "rgb(204,90,99)"
      // }, {
      //   "value": 33,
      //   "color": "rgb(169,56,94)"
      // }, {
      //   "value": 36,
      //   "color": "rgb(143,33,76)"
      // }, {
      //   "value": 39,
      //   "color": "rgb(105,25,34)"
      // }],
    ],
    grade: [
      {
        value: 1,
        color: "rgb(107,174,220)",
      },
      {
        value: 2,
        color: "rgb(72,160,139)",
      },
      {
        value: 3,
        color: "rgb(103,190,74)",
      },
      {
        value: 4,
        color: "rgb(249,198,79)",
      },
      {
        value: 5,
        color: "rgb(245,109,42)",
      },
      {
        value: 6,
        color: "rgb(188,39,65)",
      },
      {
        value: 7,
        color: "rgb(162,48,93)",
      },
    ],
    effect: [
      {
        value: 0,
        color: "rgb(255,255,255)",
      },
      {
        value: 50,
        color: "rgb(193,231,249)",
      },
      {
        value: 60,
        color: "rgb(107,174,220)",
      },
      {
        value: 70,
        color: "rgb(103,190,74)",
      },
      {
        value: 80,
        color: "rgb(249,198,79)",
      },
      {
        value: 90,
        color: "rgb(228,67,40)",
      },
      {
        value: 100,
        color: "rgb(162,48,93)",
      },
    ],
    wave: [
      {
        value: 0,
        color: "rgb(193,231,249)",
      },
      { value: 0.3, color: "rgb(150, 200, 230)" },
      {
        value: 0.6,
        color: "rgb(107,174,220)",
      },
      // { value: 0.3 * 1.0, color: "rgb(102,198,170)" },

      // { value: 0.4 * 1.0, color: "rgb(60, 180, 200)" },

      { value: 0.9, color: "rgb(34,177,233)" },

      // { value: 0.8, color: "rgb(134,190,150)" },

      { value: 1.2, color: "rgb(216,211,65)" },
      { value: 1.5, color: "rgb(232,180,60)" },
      { value: 1.8, color: "rgb(233,146,69)" },
      { value: 2.1, color: "rgb(230,117,77)" },
      { value: 2.4, color: "rgb(227,101,89)" },
      { value: 2.7, color: "rgb(222,84,100)" },
      { value: 3.0, color: "rgb(220,75,116)" },
      { value: 3.3, color: "rgb(225,79,141)" },

      {
        value: 3.6,
        color: "rgb(245,109,42)",
      },
      {
        value: 4,
        color: "rgb(228,67,40)",
      },
      {
        value: 4.5,
        color: "rgb(188,39,65)",
      },
      {
        value: 5,
        color: "rgb(162,48,93)",
      },

      // { value: 0, color: "rgb(41, 121, 142)" },
      // { value: 0.2, color: "rgb(33, 143, 141)" },
      // { value: 0.4, color: "rgb(93, 200, 98)" },
      // { value: 0.6, color: "rgb(102,198,170)" },
      // { value: 0.8, color: "rgb(34,177,233)" },

      // { color: "rgb(0, 0, 232)", value: 0 },
      // { color: "rgb(0, 71, 255)", value: 0.1 },
      // { color: "rgb(0, 162, 255)", value: 0.3 },
      // { color: "rgb(0, 255, 255)", value: 0.5 },
      // { color: "rgb(91, 255, 163)", value: 0.7 },
      // { color: "rgb(185, 255, 69)", value: 0.9 },
      // { value: 1.0, color: "rgb(176,220,97)" },
      // { value: 1.2, color: "rgb(216,211,65)" },
      // { value: 1.4, color: "rgb(232,180,60)" },
      // { value: 1.6, color: "rgb(233,146,69)" },
      // { value: 1.8, color: "rgb(230,117,77)" },
      // { value: 2.0, color: "rgb(227,101,89)" },
      // { value: 2.2, color: "rgb(222,84,100)" },
      // { value: 2.4, color: "rgb(220,75,116)" },
      // { value: 2.6, color: "rgb(225,79,141)" },
      // { value: 2.8, color: "rgb(235,99,175)" },
      // { value: 3.0, color: "rgb(245,116,206)" },
      // { value: 3.2, color: "rgb(243,123,229)" },
      // { value: 3.4, color: "rgb(223,116,246)" },
      // { value: 3.6, color: "rgb(182,90,251)" },
      // { value: 3.8, color: "rgb(147,89,251)" },
      // { value: 4.0, color: "rgb(113,112,248)" },

      // { value: 4.2, color: "rgb(81,145,243)" },
      // { value: 4.4, color: "rgb(50,178,239)" },
      // { value: 4.6, color: "rgb(20,212,235)" },
      // { value: 4.8, color: "rgb(5,226,234)" },
      // { value: 5.0, color: "rgb(0,232,232)" },
    ],
    rwave: [
      { color: "rgb(0, 0, 232)", value: 0 },
      { color: "rgb(0, 71, 255)", value: 0.5 },
      { color: "rgb(0, 162, 255)", value: 1 },
      { color: "rgb(0, 255, 255)", value: 1.5 },
      { color: "rgb(91, 255, 163)", value: 2 },
      { color: "rgb(185, 255, 69)", value: 2.5 },
      { color: "rgb(0, 255, 0)", value: 3 },
      { color: "rgb(128,255,0)", value: 3.5 },
      { color: "rgb(255, 255, 0)", value: 4 },
      { color: "rgb(255, 143, 0)", value: 5 },
      { color: "rgb(210, 0, 0)", value: 7 },
      { color: "rgb(132, 21, 22)", value: 10 },
    ],
    rtpwave: [
      { color: "rgb(0, 31, 255)", value: 0 },
      { color: "rgb(71, 94, 255)", value: 2 },
      { color: "rgb(54, 152, 237)", value: 3 },
      { color: "rgb(253, 255, 0)", value: 4 },
      { color: "rgb(208, 88, 44)", value: 6 },
      { color: "rgb(250, 11, 10)", value: 9 },
      { color: "rgb(187, 13, 19)", value: 14 },
    ],
    windFeather: [
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 64,
        g: 131,
        b: 184,
      },
      {
        r: 65,
        g: 133,
        b: 182,
      },
      {
        r: 66,
        g: 134,
        b: 181,
      },
      {
        r: 65,
        g: 136,
        b: 180,
      },
      {
        r: 66,
        g: 138,
        b: 178,
      },
      {
        r: 67,
        g: 139,
        b: 177,
      },
      {
        r: 68,
        g: 141,
        b: 174,
      },
      {
        r: 69,
        g: 142,
        b: 174,
      },
      {
        r: 69,
        g: 145,
        b: 171,
      },
      {
        r: 70,
        g: 146,
        b: 170,
      },
      {
        r: 70,
        g: 147,
        b: 167,
      },
      {
        r: 72,
        g: 149,
        b: 167,
      },
      {
        r: 72,
        g: 149,
        b: 165,
      },
      {
        r: 72,
        g: 152,
        b: 163,
      },
      {
        r: 73,
        g: 153,
        b: 160,
      },
      {
        r: 74,
        g: 155,
        b: 159,
      },
      {
        r: 75,
        g: 156,
        b: 157,
      },
      {
        r: 74,
        g: 159,
        b: 156,
      },
      {
        r: 75,
        g: 160,
        b: 153,
      },
      {
        r: 75,
        g: 161,
        b: 150,
      },
      {
        r: 76,
        g: 162,
        b: 149,
      },
      {
        r: 77,
        g: 164,
        b: 147,
      },
      {
        r: 77,
        g: 166,
        b: 146,
      },
      {
        r: 78,
        g: 168,
        b: 143,
      },
      {
        r: 79,
        g: 169,
        b: 141,
      },
      {
        r: 80,
        g: 171,
        b: 140,
      },
      {
        r: 78,
        g: 172,
        b: 136,
      },
      {
        r: 78,
        g: 173,
        b: 133,
      },
      {
        r: 78,
        g: 174,
        b: 128,
      },
      {
        r: 78,
        g: 175,
        b: 124,
      },
      {
        r: 77,
        g: 176,
        b: 121,
      },
      {
        r: 77,
        g: 177,
        b: 115,
      },
      {
        r: 76,
        g: 178,
        b: 112,
      },
      {
        r: 77,
        g: 180,
        b: 109,
      },
      {
        r: 77,
        g: 181,
        b: 104,
      },
      {
        r: 75,
        g: 182,
        b: 100,
      },
      {
        r: 75,
        g: 183,
        b: 97,
      },
      {
        r: 74,
        g: 185,
        b: 93,
      },
      {
        r: 74,
        g: 186,
        b: 88,
      },
      {
        r: 76,
        g: 186,
        b: 87,
      },
      {
        r: 78,
        g: 186,
        b: 85,
      },
      {
        r: 79,
        g: 187,
        b: 85,
      },
      {
        r: 79,
        g: 188,
        b: 83,
      },
      {
        r: 81,
        g: 188,
        b: 82,
      },
      {
        r: 82,
        g: 190,
        b: 81,
      },
      {
        r: 83,
        g: 189,
        b: 79,
      },
      {
        r: 86,
        g: 190,
        b: 79,
      },
      {
        r: 87,
        g: 191,
        b: 78,
      },
      {
        r: 87,
        g: 191,
        b: 76,
      },
      {
        r: 89,
        g: 192,
        b: 74,
      },
      {
        r: 91,
        g: 192,
        b: 74,
      },
      {
        r: 92,
        g: 193,
        b: 73,
      },
      {
        r: 94,
        g: 194,
        b: 72,
      },
      {
        r: 96,
        g: 194,
        b: 73,
      },
      {
        r: 98,
        g: 194,
        b: 71,
      },
      {
        r: 101,
        g: 195,
        b: 73,
      },
      {
        r: 103,
        g: 195,
        b: 71,
      },
      {
        r: 105,
        g: 195,
        b: 72,
      },
      {
        r: 107,
        g: 195,
        b: 73,
      },
      {
        r: 110,
        g: 196,
        b: 73,
      },
      {
        r: 111,
        g: 197,
        b: 74,
      },
      {
        r: 115,
        g: 197,
        b: 73,
      },
      {
        r: 117,
        g: 197,
        b: 74,
      },
      {
        r: 118,
        g: 198,
        b: 73,
      },
      {
        r: 119,
        g: 198,
        b: 73,
      },
      {
        r: 123,
        g: 200,
        b: 72,
      },
      {
        r: 127,
        g: 199,
        b: 73,
      },
      {
        r: 128,
        g: 200,
        b: 72,
      },
      {
        r: 131,
        g: 200,
        b: 71,
      },
      {
        r: 134,
        g: 201,
        b: 70,
      },
      {
        r: 136,
        g: 202,
        b: 70,
      },
      {
        r: 139,
        g: 202,
        b: 71,
      },
      {
        r: 142,
        g: 204,
        b: 71,
      },
      {
        r: 143,
        g: 203,
        b: 69,
      },
      {
        r: 147,
        g: 205,
        b: 69,
      },
      {
        r: 150,
        g: 204,
        b: 67,
      },
      {
        r: 153,
        g: 205,
        b: 68,
      },
      {
        r: 154,
        g: 205,
        b: 68,
      },
      {
        r: 158,
        g: 206,
        b: 68,
      },
      {
        r: 160,
        g: 207,
        b: 67,
      },
      {
        r: 163,
        g: 208,
        b: 66,
      },
      {
        r: 165,
        g: 208,
        b: 67,
      },
      {
        r: 169,
        g: 208,
        b: 67,
      },
      {
        r: 171,
        g: 208,
        b: 66,
      },
      {
        r: 174,
        g: 209,
        b: 65,
      },
      {
        r: 176,
        g: 210,
        b: 64,
      },
      {
        r: 178,
        g: 210,
        b: 65,
      },
      {
        r: 182,
        g: 212,
        b: 66,
      },
      {
        r: 183,
        g: 211,
        b: 64,
      },
      {
        r: 188,
        g: 212,
        b: 64,
      },
      {
        r: 188,
        g: 212,
        b: 64,
      },
      {
        r: 190,
        g: 212,
        b: 65,
      },
      {
        r: 192,
        g: 212,
        b: 65,
      },
      {
        r: 193,
        g: 211,
        b: 63,
      },
      {
        r: 195,
        g: 211,
        b: 63,
      },
      {
        r: 197,
        g: 211,
        b: 64,
      },
      {
        r: 197,
        g: 211,
        b: 62,
      },
      {
        r: 199,
        g: 211,
        b: 63,
      },
      {
        r: 201,
        g: 211,
        b: 63,
      },
      {
        r: 202,
        g: 210,
        b: 62,
      },
      {
        r: 204,
        g: 210,
        b: 62,
      },
      {
        r: 206,
        g: 210,
        b: 63,
      },
      {
        r: 206,
        g: 210,
        b: 63,
      },
      {
        r: 205,
        g: 209,
        b: 62,
      },
      {
        r: 206,
        g: 208,
        b: 62,
      },
      {
        r: 207,
        g: 207,
        b: 61,
      },
      {
        r: 208,
        g: 208,
        b: 62,
      },
      {
        r: 208,
        g: 205,
        b: 62,
      },
      {
        r: 208,
        g: 205,
        b: 62,
      },
      {
        r: 209,
        g: 204,
        b: 61,
      },
      {
        r: 209,
        g: 204,
        b: 61,
      },
      {
        r: 210,
        g: 203,
        b: 61,
      },
      {
        r: 209,
        g: 202,
        b: 60,
      },
      {
        r: 210,
        g: 201,
        b: 60,
      },
      {
        r: 211,
        g: 199,
        b: 61,
      },
      {
        r: 211,
        g: 199,
        b: 61,
      },
      {
        r: 212,
        g: 199,
        b: 61,
      },
      {
        r: 212,
        g: 199,
        b: 61,
      },
      {
        r: 213,
        g: 197,
        b: 60,
      },
      {
        r: 213,
        g: 197,
        b: 62,
      },
      {
        r: 213,
        g: 195,
        b: 61,
      },
      {
        r: 214,
        g: 194,
        b: 61,
      },
      {
        r: 213,
        g: 193,
        b: 60,
      },
      {
        r: 215,
        g: 192,
        b: 62,
      },
      {
        r: 215,
        g: 190,
        b: 61,
      },
      {
        r: 215,
        g: 190,
        b: 61,
      },
      {
        r: 216,
        g: 189,
        b: 60,
      },
      {
        r: 216,
        g: 188,
        b: 62,
      },
      {
        r: 216,
        g: 187,
        b: 61,
      },
      {
        r: 216,
        g: 184,
        b: 61,
      },
      {
        r: 215,
        g: 183,
        b: 62,
      },
      {
        r: 216,
        g: 181,
        b: 63,
      },
      {
        r: 216,
        g: 179,
        b: 62,
      },
      {
        r: 215,
        g: 178,
        b: 63,
      },
      {
        r: 216,
        g: 176,
        b: 63,
      },
      {
        r: 216,
        g: 174,
        b: 64,
      },
      {
        r: 215,
        g: 173,
        b: 65,
      },
      {
        r: 214,
        g: 170,
        b: 63,
      },
      {
        r: 216,
        g: 169,
        b: 65,
      },
      {
        r: 215,
        g: 167,
        b: 65,
      },
      {
        r: 215,
        g: 165,
        b: 66,
      },
      {
        r: 216,
        g: 164,
        b: 65,
      },
      {
        r: 215,
        g: 162,
        b: 66,
      },
      {
        r: 215,
        g: 161,
        b: 65,
      },
      {
        r: 215,
        g: 159,
        b: 66,
      },
      {
        r: 215,
        g: 158,
        b: 68,
      },
      {
        r: 214,
        g: 157,
        b: 67,
      },
      {
        r: 215,
        g: 155,
        b: 67,
      },
      {
        r: 214,
        g: 154,
        b: 68,
      },
      {
        r: 214,
        g: 152,
        b: 69,
      },
      {
        r: 213,
        g: 151,
        b: 68,
      },
      {
        r: 214,
        g: 149,
        b: 69,
      },
      {
        r: 214,
        g: 149,
        b: 69,
      },
      {
        r: 214,
        g: 147,
        b: 69,
      },
      {
        r: 214,
        g: 147,
        b: 69,
      },
      {
        r: 214,
        g: 145,
        b: 70,
      },
      {
        r: 213,
        g: 144,
        b: 69,
      },
      {
        r: 213,
        g: 143,
        b: 71,
      },
      {
        r: 214,
        g: 142,
        b: 70,
      },
      {
        r: 214,
        g: 141,
        b: 72,
      },
      {
        r: 214,
        g: 139,
        b: 71,
      },
      {
        r: 214,
        g: 139,
        b: 72,
      },
      {
        r: 213,
        g: 138,
        b: 71,
      },
      {
        r: 215,
        g: 137,
        b: 73,
      },
      {
        r: 214,
        g: 136,
        b: 72,
      },
      {
        r: 215,
        g: 135,
        b: 74,
      },
      {
        r: 213,
        g: 133,
        b: 72,
      },
      {
        r: 214,
        g: 132,
        b: 74,
      },
      {
        r: 213,
        g: 131,
        b: 73,
      },
      {
        r: 215,
        g: 130,
        b: 75,
      },
      {
        r: 214,
        g: 129,
        b: 74,
      },
      {
        r: 214,
        g: 129,
        b: 75,
      },
      {
        r: 214,
        g: 127,
        b: 74,
      },
      {
        r: 213,
        g: 125,
        b: 75,
      },
      {
        r: 213,
        g: 125,
        b: 75,
      },
      {
        r: 214,
        g: 123,
        b: 76,
      },
      {
        r: 214,
        g: 123,
        b: 76,
      },
      {
        r: 214,
        g: 121,
        b: 77,
      },
      {
        r: 214,
        g: 121,
        b: 77,
      },
      {
        r: 213,
        g: 120,
        b: 77,
      },
      {
        r: 214,
        g: 118,
        b: 78,
      },
      {
        r: 213,
        g: 116,
        b: 81,
      },
      {
        r: 213,
        g: 114,
        b: 82,
      },
      {
        r: 211,
        g: 112,
        b: 83,
      },
      {
        r: 211,
        g: 109,
        b: 84,
      },
      {
        r: 210,
        g: 108,
        b: 85,
      },
      {
        r: 211,
        g: 106,
        b: 87,
      },
      {
        r: 208,
        g: 105,
        b: 88,
      },
      {
        r: 209,
        g: 103,
        b: 89,
      },
      {
        r: 208,
        g: 102,
        b: 89,
      },
      {
        r: 208,
        g: 99,
        b: 92,
      },
      {
        r: 206,
        g: 97,
        b: 92,
      },
      {
        r: 207,
        g: 95,
        b: 94,
      },
      {
        r: 206,
        g: 93,
        b: 95,
      },
      {
        r: 206,
        g: 91,
        b: 98,
      },
      {
        r: 205,
        g: 89,
        b: 98,
      },
      {
        r: 203,
        g: 87,
        b: 100,
      },
      {
        r: 203,
        g: 84,
        b: 103,
      },
      {
        r: 202,
        g: 83,
        b: 103,
      },
      {
        r: 203,
        g: 81,
        b: 106,
      },
      {
        r: 202,
        g: 79,
        b: 107,
      },
      {
        r: 201,
        g: 78,
        b: 109,
      },
      {
        r: 200,
        g: 75,
        b: 109,
      },
      {
        r: 199,
        g: 73,
        b: 111,
      },
      {
        r: 200,
        g: 71,
        b: 112,
      },
      {
        r: 197,
        g: 70,
        b: 111,
      },
      {
        r: 196,
        g: 69,
        b: 110,
      },
      {
        r: 195,
        g: 68,
        b: 109,
      },
      {
        r: 194,
        g: 67,
        b: 108,
      },
      {
        r: 193,
        g: 68,
        b: 108,
      },
      {
        r: 192,
        g: 67,
        b: 107,
      },
      {
        r: 191,
        g: 66,
        b: 106,
      },
      {
        r: 188,
        g: 66,
        b: 105,
      },
      {
        r: 187,
        g: 65,
        b: 104,
      },
      {
        r: 186,
        g: 66,
        b: 104,
      },
      {
        r: 185,
        g: 65,
        b: 103,
      },
      {
        r: 184,
        g: 64,
        b: 102,
      },
      {
        r: 182,
        g: 63,
        b: 101,
      },
      {
        r: 181,
        g: 62,
        b: 100,
      },
      {
        r: 180,
        g: 61,
        b: 99,
      },
      {
        r: 180,
        g: 61,
        b: 99,
      },
      {
        r: 176,
        g: 60,
        b: 99,
      },
      {
        r: 176,
        g: 60,
        b: 97,
      },
      {
        r: 175,
        g: 59,
        b: 96,
      },
      {
        r: 174,
        g: 58,
        b: 95,
      },
      {
        r: 172,
        g: 58,
        b: 94,
      },
      {
        r: 171,
        g: 56,
        b: 95,
      },
      {
        r: 170,
        g: 55,
        b: 94,
      },
      {
        r: 168,
        g: 56,
        b: 92,
      },
      {
        r: 167,
        g: 55,
        b: 93,
      },
      {
        r: 167,
        g: 55,
        b: 93,
      },
      {
        r: 165,
        g: 55,
        b: 92,
      },
      {
        r: 165,
        g: 55,
        b: 92,
      },
      {
        r: 166,
        g: 54,
        b: 92,
      },
      {
        r: 166,
        g: 54,
        b: 92,
      },
      {
        r: 164,
        g: 54,
        b: 91,
      },
      {
        r: 164,
        g: 54,
        b: 91,
      },
      {
        r: 164,
        g: 54,
        b: 91,
      },
      {
        r: 164,
        g: 54,
        b: 91,
      },
      {
        r: 163,
        g: 53,
        b: 90,
      },
      {
        r: 163,
        g: 53,
        b: 90,
      },
      {
        r: 163,
        g: 53,
        b: 90,
      },
    ],
    surge:  [
      { "value": -100, "color": "rgb(0, 0, 159)" },
      { "value": -80, "color": "rgb(0, 0, 239)" },
      { "value": -60, "color": "rgb(0, 79, 255)" },
      { "value": -40, "color": "rgb(0, 175, 255)" },
      { "value": -20, "color": "rgb(15, 255, 239)" },
      { "value": 0, "color": "rgb(111, 255, 143)" },
      { "value": 20, "color": "rgb(207, 255, 47)" },
      { "value": 40, "color": "rgb(255, 207, 0)" },
      { "value": 60, "color": "rgb(255, 111, 0)" },
      { "value": 80, "color": "rgb(255, 15, 0)" },
      { "value": 100, "color": "rgb(143, 0, 0)" },
  ],
    current: [
      {
        value: 0,
        color: "rgb(69,120,211)",
      },
      {
        value: 0.1,
        color: "rgb(73,150,166)",
      },
      {
        value: 0.2,
        color: "rgb(82,185,94)",
      },
      {
        value: 0.4,
        color: "rgb(143,202,74)",
      },
      {
        value: 0.6,
        color: "rgb(200,207,63)",
      },
      {
        value: 0.8,
        color: "rgb(235,192,56)",
      },
      {
        value: 1.0,
        color: "rgb(216,179,64)",
      },
      {
        value: 1.1,
        color: "rgb(234,164,62)",
      },
      {
        value: 1.2,
        color: "rgb(216,139,73)",
      },
      {
        value: 1.3,
        color: "rgb(233, 123, 72)",
      },
      {
        value: 1.4,
        color: "rgb(225,94,93)",
      },
      {
        value: 1.5,
        color: "rgb(190,58,102)",
      },
    ],
    current_speed: [
      { value: 0, color: "rgb(22,173,244)" },
      { value: 0.2, color: "rgb(22,173,244)" },
      { value: 0.4, color: "rgb(15,171,246)" },
      { value: 0.6, color: "rgb(81,192,186)" },
      { value: 0.8, color: "rgb(161,217,110)" },
      { value: 1.0, color: "rgb(209,217,69)" },
      { value: 1.2, color: "rgb(231,195,57)" },
      { value: 1.4, color: "rgb(233,159,64)" },
      { value: 1.6, color: "rgb(231,131,72)" },
      { value: 1.8, color: "rgb(228,105,87)" },
      { value: 2.0, color: "rgb(223,87,99)" },
      { value: 2.2, color: "rgb(222,76,123)" },
      { value: 2.5, color: "rgb(230,86,155)" },
      { value: 2.6, color: "rgb(241,109,193)" },
      { value: 2.8, color: "rgb(244,123,229)" },
      { value: 3.0, color: "rgb(215,112,247)" },
      { value: 3.2, color: "rgb(157,89,250)" },
      { value: 3.4, color: "rgb(117,108,249)" },
      { value: 3.6, color: "rgb(79,149,244)" },
      { value: 3.8, color: "rgb(41,189,237)" },
      { value: 4.0, color: "rgb(12,220,233)" },
      { value: 4.2, color: "rgb(0,232,232)" },
      { value: 4.4, color: "rgb(0,232,232)" },
    ],
    surge: [
      { "value": -100, "color": "rgb(0, 0, 159)" },
      { "value": -80, "color": "rgb(0, 0, 239)" },
      { "value": -60, "color": "rgb(0, 79, 255)" },
      { "value": -40, "color": "rgb(0, 175, 255)" },
      { "value": -20, "color": "rgb(15, 255, 239)" },
      { "value": 0, "color": "rgb(111, 255, 143)" },
      { "value": 20, "color": "rgb(207, 255, 47)" },
      { "value": 40, "color": "rgb(255, 207, 0)" },
      { "value": 60, "color": "rgb(255, 111, 0)" },
      { "value": 80, "color": "rgb(255, 15, 0)" },
      { "value": 100, "color": "rgb(143, 0, 0)" },
  ],
  seatemp: [
    { "value": -3, "color": "rgb(190,190,190)" },
    { "value": -1, "color": "rgb(167,169,182)" },
    { "value": 1, "color": "rgb(142,141,172)" },
    { "value": 3, "color": "rgb(110,93,145)" },
    { "value": 5, "color": "rgb(44,36,96)" },
    { "value": 7, "color": "rgb(59,54,121)" },
    { "value": 9, "color": "rgb(68,76,141)" },
    { "value": 11, "color": "rgb(66,96,150)" },
    { "value": 13, "color": "rgb(63,120,149)" },
    { "value": 15, "color": "rgb(69,141,127)" },
    { "value": 17, "color": "rgb(76,157,101)" },
    { "value": 19, "color": "rgb(94,167,78)" },
    { "value": 21, "color": "rgb(129,176,64)" },
    { "value": 23, "color": "rgb(168,179,57)" },
    { "value": 25, "color": "rgb(181,168,54)" },
    { "value": 27, "color": "rgb(187,154,57)" },
    { "value": 29, "color": "rgb(185,138,60)" },
    { "value": 31, "color": "rgb(185,115,64)" },
    { "value": 33, "color": "rgb(180,91,77)" },
    { "value": 35, "color": "rgb(168,69,89)" },
    { "value": 37, "color": "rgb(148,53,85)" },
    { "value": 39, "color": "rgb(127,38,68)" },
],
temp: [
  { "value": -55, "color": "rgb(207,172,195)" },
  { "value": -40, "color": "rgb(162,70,145)" },
  { "value": -25, "color": "rgb(143,89,169)" },
  { "value": -15, "color": "rgb(157,219,217)" },
  { "value": -8, "color": "rgb(106,191,181)" },
  { "value": -4, "color": "rgb(100,166,189)" },
  { "value": 0, "color": "rgb(93,133,198)" },
  { "value": 1, "color": "rgb(68,125,99)" },
  { "value": 10, "color": "rgb(128,147,24)" },
  { "value": 21, "color": "rgb(243,183,4)" },
  { "value": 30, "color": "rgb(232,83,25)" },
  { "value": 47, "color": "rgb(71,14,0)" }
],
    // current_speed10: [
    //   { value: 0*10.0, color: "rgb(22,173,244)" },
    //   { value: 0.2*10.0+1, color: "rgb(22,173,244)" },
    //   { value: 0.4*10.0+1, color: "rgb(15,171,246)" },
    //   { value: 0.6*10.0+1, color: "rgb(81,192,186)" },
    //   { value: 0.8*10.0+1, color: "rgb(161,217,110)" },
    //   { value: 1.0*10.0+1, color: "rgb(209,217,69)" },
    //   { value: 1.2*10.0+1, color: "rgb(231,195,57)" },
    //   { value: 1.4*10.0+1, color: "rgb(233,159,64)" },
    //   { value: 1.6*10.0+1, color: "rgb(231,131,72)" },
    //   { value: 1.8*10.0+1, color: "rgb(228,105,87)" },
    //   { value: 2.0*10.0+1, color: "rgb(223,87,99)" },
    //   { value: 2.2*10.0+1, color: "rgb(222,76,123)" },
    //   { value: 2.5*10.0+1, color: "rgb(230,86,155)" },
    //   { value: 2.6*10.0+1, color: "rgb(241,109,193)" },
    //   { value: 2.8*10.0+1, color: "rgb(244,123,229)" },
    //   { value: 3.0*10.0+1, color: "rgb(215,112,247)" },
    //   { value: 3.2*10.0+1, color: "rgb(157,89,250)" },
    //   { value: 3.4*10.0+1, color: "rgb(117,108,249)" },
    //   { value: 3.6*10.0+1, color: "rgb(79,149,244)" },
    //   { value: 3.8*10.0+1, color: "rgb(41,189,237)" },
    //   { value: 4.0*10.0+1, color: "rgb(12,220,233)" },
    //   { value: 4.2*10.0+1, color: "rgb(0,232,232)" },
    //   { value: 4.4*10.0+1, color: "rgb(0,232,232)" },
    // ],
  },
};
export default Config;
let map = null,
  thisUData = [],
  thisVData = [],
  thisGridData = [];
export const initMap = () => {
  Config.AllLayers = {
    surgeLayer: ScalarLayer({
      //増水
      scalarColor: Config.scalarColor.surge,
      zindex: 99,
      opacity: 0.9,
      type: "surge",
      surgeTP: "",
      showLabel: false,
      magnification: 1, //画布缩放比例
    }),
    currentLayer: ParticleLayer({
      //精细化流场粒子
      zindex: 99,
      magnification: 1, //画布缩放比例
      color: ["rgba(255,81,0,1)"],
      velocityScale: 0.08, //步长，流动速度(尽量不变)
      globalAlpha: 0.9, //全局透明度
      particleAge: 60, //粒子生命周期
      particleMultiplier: 600, //密度
      frame_rate: 20, //刷新率
      lineWidth: 1, //线宽
      type: "current",
    }),
    waveLayer: ScalarLayer({
      //浪
      scalarColor: Config.scalarColor.wave,
      zindex: 99,
      opacity: 1.0,
      type: "wave",
      showLabel: false,
      magnification: 1,
    }),
    awindLayer: ScalarLayer({
      //预报风
      scalarColor: Config.scalarColor.awind,
      zindex: 99,
      opacity: 1.0,
      type: "awind",
      showLabel: false,
      magnification: 1,
    }),
    windLayer: ScalarLayer({
      //风
      scalarColor: Config.scalarColor.wind,
      zindex: 99,
      opacity: 1.0,
      type: "wind",
      showLabel: false,
      magnification: 1,
    }),
    windEngryLayer: ScalarLayer({
      //风功率
      scalarColor: Config.scalarColor.windEngry,
      zindex: 99,
      opacity: 1.0,
      type: "windEngry",
      showLabel: false,
      magnification: 1,
    }),
    gradeLayer: ScalarLayer({
      //等级
      scalarColor: Config.scalarColor.grade,
      zindex: 99,
      opacity: 1.0,
      type: "grade",
      showLabel: false,
      magnification: 1,
    }),
    effectLayer: ScalarLayer({
      //有效风时
      scalarColor: Config.scalarColor.effect,
      zindex: 99,
      opacity: 1.0,
      type: "effect",
      showLabel: false,
      magnification: 1,
    }),
    tianditu_v: L.tileLayer(
      // "https://www.oceanread.com:444/esriCOC/{z}/{y}/{x}.png",
      // http://t0.tianditu.gov.cn/cva_c/wmts
      // "http://t0.tianditu.gov.cn/cva_c/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=f8062052955771bbb835dbdb050610c1",
      // "http://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=848089cab53a169cef2cabdc84c8f644",
      // "http://localhost:2433/map/{z}/{y}/{x}.png",
      "https://www.oceanread.com:444/esriCOC/{z}/{y}/{x}.png",

      {
        //   maxZoom: 10,
        //   minZoom: 2,
      }
    ),
    zj: L.tileLayer(
      "http://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=848089cab53a169cef2cabdc84c8f644",
      {
        // subdomains : ['0', '1', '2', '3', '4', '5', '6', '7'],
        pane: "overlayPane",
        zIndex: 501,
      }
    ),
    // tianditu_v_nosea: L.tileLayer(
    //   "https://www.oceanread.com:444/esriCOC_withoutsea/{z}/{y}/{x}.png", //"http://www.oceanread.com:8066/esriCOC_withoutsea/{z}/{y}/{x}.png",
    //   {
    //     pane: "overlayPane",
    //     zIndex: 500,
    //   }
    // ),
    // tianditu_v_nosea: new TileLayerCALCSHA1(
    //   "https://gg.oceanread.com:1008/yhbasemap/tianditu/nosea/vec_w_encrypt/{z}/{y}/{x}.png",
    //   {
    //     codeArr: [17, 8, 5, 4, 25, 39],
    //     pane: "overlayPane",
    //     zIndex: 500,
    //   }
    // ),
  };
  Config.ToolLayers = L.layerGroup().addTo(Config.mapObj.map);
  // 添加底图
  // Config.AllLayers.tianditu_v.addTo(Config.mapObj.map);

  Config.mapObj.map.createPane('drawingPane');
  Config.mapObj.map.getPane('drawingPane').style.zIndex = 650;

  // allLayersQin();
  thisLayerG.addTo(Config.mapObj.map);
  thisLayerL.addTo(Config.mapObj.map);
};

const computeWindUV = (u_value, v_value) => {
  let value = Math.sqrt(u_value * u_value + v_value * v_value);
  let angle = Math.acos(u_value / value);
  if (v_value < 0) {
    angle = -angle;
  }
  angle = Math.round((angle / Math.PI) * 180.0 + 90);
  if (angle < 0) {
    angle = angle + 360;
  }
  angle = Math.round(360 - angle);
  value = value.toFixed(2);
  return {
    value: parseFloat(value),
    angle: angle,
  };
};

let UV2SDCur = function (u, v) {
  let spd, dir;
  if (u === 0 && v === 0) {
    spd = 0;
    dir = -9999;
    return { speed: spd, dir: dir };
  }

  if (u === 0 || v === 0) {
    if (u === 0) {
      spd = v < 0 ? -v : v;
      if (v > 0) {
        dir = Math.PI / 2;
      } else if (v < 0) {
        dir = (Math.PI * 3) / 2;
      }
    } else if (v === 0) {
      spd = u < 0 ? -u : u;
      if (u > 0) {
        dir = 0;
      } else if (u < 0) {
        dir = Math.PI;
      }
    }
    dir = (2.5 * Math.PI - dir) % (Math.PI * 2);
    return { speed: spd, dir: dir };
  }

  spd = Math.sqrt(u * u + v * v);
  dir = Math.atan(u / v);
  if (u < 0 && v > 0) {
    dir = (1 / 2.0) * Math.PI - dir;
  } else if (u < 0 && v < 0) {
    dir = (3 / 2.0) * Math.PI - dir;
  } else if (u > 0 && v < 0) {
    dir = (3 / 2.0) * Math.PI - dir;
  } else if (u > 0 && v > 0) {
    dir = (1 / 2.0) * Math.PI - dir;
  }
  dir = (2.5 * Math.PI - dir) % (Math.PI * 2);
  return { speed: spd, dir: dir };
};

// 弧度转角度
let radianToAngle = function (radian) {
  return (radian * 180) / Math.PI;
};
/**当前绘图的图层组 */
export let thisLayerG = L.layerGroup();
export let thisLayerL = L.layerGroup();
const GetUV = (angle, type) => {
  // let u = Math.sin((angle * Math.PI) / 180);
  // let v = Math.cos((angle * Math.PI) / 180);
  let u = Math.cos((angle * Math.PI) / 180);
  let v = Math.sin((angle * Math.PI) / 180);
  if (type == "U") {
    return -u;
  } else {
    return -v;
  }
};
export let pointInfo = [];
export const addForecastLayer = (pa) => {
  // thisLayerG.addTo(Config.mapObj.map);
  let pngUrl = `${pa.common.url}`;
  let dataType = pa.attribute.type;
  let calRegion = pa.attribute.calRegion;
  let dataRange = pa.common.range;
  let image = new Image();
  image.crossOrigin = "Anonymous";
  image.src = pngUrl;
  image.onload = function () {
    let can = document.createElement("canvas");
    can.width = image.width;
    can.height = image.height;
    let ImgdataCtx = can.getContext("2d");
    ImgdataCtx.drawImage(image, 0, 0);
    let image0 = ImgdataCtx.getImageData(0, 0, image.width, image.height);
    let imgdat0 = image0.data;

    if (dataType == "wind") {
      thisUData = [];
      thisVData = [];
      let k = -1;
      for (let i = 0; i < image0.height; i++) {
        for (let j = 0; j < image0.width; j++) {
          k++;
          let x = i * 4 * image0.width + j * 4;
          let r = imgdat0[x],
            g = imgdat0[x + 1],
            b = imgdat0[x + 2],
            a = imgdat0[x + 3];
          let u = b >= 10 ? r / 10 : -(r / 10);
          let v = b % 10 == 1 ? g / 10 : -(g / 10);
          thisUData[k] = u;
          thisVData[k] = v;
        }
      }


    } else if (dataType == "current") {
      thisUData = [];
      thisVData = [];
      let k = -1;
      for (let i = 0; i < image0.height; i++) {
        for (let j = 0; j < image0.width; j++) {
          k++;
          let x = i * 4 * image0.width + j * 4;
          let r = imgdat0[x],
            g = imgdat0[x + 1],
            b = imgdat0[x + 2],
            a = imgdat0[x + 3];
          let u = 0,
            v = 0;
          if (a != 0) {
            u = r / 100.0;
            v = g / 100.0;
            if (b == 0) {
              u = -u;
              v = -v;
            } else if (b == 1) {
              u = -u;
            } else if (b == 10) {
              v = -v;
            }
          }
          thisUData[k] = u;
          thisVData[k] = v;
        }
      }
    } else if (dataType == "wave") {
      thisUData = [];
      thisVData = [];
      let k = -1;
      for (let i = 0; i < image0.height; i++) {
        for (let j = 0; j < image0.width; j++) {
          // = j + 3 = i + 3
          k++;
          let x = i * 4 * image0.width + j * 4;
          let r = imgdat0[x],
            g = imgdat0[x + 1],
            b = imgdat0[x + 2],
            a = imgdat0[x + 3];

          let value_w = r + g / 100;
          let angle_origin_w = (b / 255) * 360;
          let angle = angle_origin_w % 360;
          let u = 0,
            v = 0;
          if (a > 0) {
            u = -GetUV(angle, "U");
            v = -GetUV(angle, "V");
          }
          thisUData[k] = u.toFixed(2);
          thisVData[k] = v.toFixed(2);
          // if (a != 0) {
          //   thisUData[k] = 0
          //   thisVData[k] = 0
          // } else {
          //   thisUData[k] = GetUV(angle, "U")
          //   thisVData[k] = GetUV(angle, "V")
          // }

          // thisUData[k] = value_w;
          // thisVData[k] = +((+angle).toFixed(1));
        }
      }
      // let value_w = r + g / 100, angle_origin_w = b / 255 * 360, angle = (angle_origin_w + angleInter) % 360
      // value_0 = {
      //   value: parseFloat(value_w.toFixed(1)),
      //   angle: +((+angle).toFixed(1))
      // }
      // data[i][j] = value_0
    } else {
      pointInfo = [];
      thisGridData = [];
      for (let i = 0; i < image0.height; i++) {
        thisGridData[i] = [];
        pointInfo[i] = [];
        for (let j = 0; j < image0.width; j++) {
          let x = i * 4 * image0.width + j * 4;
          let r = imgdat0[x],
            g = imgdat0[x + 1],
            b = imgdat0[x + 2],
            a = imgdat0[x + 3];
          let value_0 = -999;
          if (dataType == "wave_height") {
            value_0 = r + g / 100;
            // value_0 = parseInt((r + g / 100) * 10.0);
            let angle_origin = (b / 255) * 360;
            let angle = angle_origin % 360;
            pointInfo[i][j] = {
              value: parseFloat(value_0.toFixed(2)),
              angle: +(+angle).toFixed(2),
            };
          } else if (dataType == "wave") {
            value_0 = r + g / 100;
          } else if (dataType == "seatemp") {
            value_0 = r + g + b / 100.0 - 273.15;
          } else if (dataType == "temp") {
            value_0 = r + g + b / 100.0 - 273.15;
          } else if (dataType == "tide") {
            value_0 = r + g / 100.0;
            if (b == 200.0) {
              value_0 = -value_0;
            }
          } else if (dataType == "sealevel") {
            value_0 = r / 100.0;
            if (b == 0 || b == 1) {
              value_0 = -value_0;
            }
          } else if (dataType == "wind_speed") {
            let u = b >= 10 ? r / 10 : -(r / 10);
            let v = b % 10 == 1 ? g / 10 : -(g / 10);
            let uvObj = computeWindUV(u, v);
            pointInfo[i][j] = {
              value: uvObj.value,
              angle: Math.abs(180 - uvObj.angle),
            };
            // value_0 = parseInt(Math.sqrt(u * u + v * v) * 10.0);
            value_0 = Math.sqrt(u * u + v * v);
          } else if (dataType == "current_speed") {
            let u = 0,
              v = 0;
            if (a != 0) {
              u = r / 100.0;
              v = g / 100.0;
              if (b == 0) {
                u = -u;
                v = -v;
              } else if (b == 1) {
                u = -u;
              } else if (b == 10) {
                v = -v;
              }
            }

            let u1 = b >= 10 ? r / 10 : -(r / 10),
              v1 = b % 10 == 1 ? g / 10 : -(g / 10);
            let uvObj = UV2SDCur(u, v);
            pointInfo[i][j] = {
              value: uvObj.speed?.toFixed(2),
              angle: radianToAngle(uvObj.dir),
              // value: u,
              // angle: v
            };
            // value_0 = parseInt(Math.sqrt(u * u + v * v) * 100.0);
            value_0 = Math.sqrt(u * u + v * v);
          }
          if (a == 0) {
            value_0 = -999;
            // value_0 = -1;
          }
          thisGridData[i][j] = value_0.toFixed(2);
        }
      }
    }
    if (pa.attribute.showFeather) {
      thisGridData = [];
      for (let i = 0; i < image0.height; i++) {
        thisGridData[i] = [];
        for (let j = 0; j < image0.width; j++) {
          let x = i * 4 * image0.width + j * 4;
          let r = imgdat0[x],
            g = imgdat0[x + 1],
            b = imgdat0[x + 2],
            a = imgdat0[x + 3];
          let value_0 = -999;
          // if (dataType == "wave") {
          //   value_0 = r + g / 100;
          // } else if (dataType == "seatemp") {
          //   value_0 = r + g + b / 100.0 - 273.15;
          // } else if (dataType == "temp") {
          //   value_0 = r + g + b / 100.0 - 273.15;
          // } else if (dataType == "tide") {
          //   value_0 = r + g / 100.0;
          //   if (b == 200.0) {
          //     value_0 = -value_0;
          //   }
          // } else if (dataType == "sealevel") {
          //   value_0 = r / 100.0;
          //   if (b == 0 || b == 1) {
          //     value_0 = -value_0;
          //   }
          // } else if (dataType == "wind_speed" || dataType == "wind") {
          //   let u = b >= 10 ? r / 10 : -(r / 10);
          //   let v = b % 10 == 1 ? g / 10 : -(g / 10);
          //   value_0 = Math.sqrt(u * u + v * v);
          // }
          // if (a == 0) {
          //   value_0 = -999;
          // }
          if (dataType == "wind") {
            let u = b >= 10 ? r / 10 : -(r / 10);
            let v = b % 10 == 1 ? g / 10 : -(g / 10);
            value_0 = { u: u, v, v };
            thisGridData[i][j] = value_0;
          }
          if (dataType == "current") {
            let u = 0,
              v = 0;
            if (a != 0) {
              u = r / 100.0;
              v = g / 100.0;
              if (b == 0) {
                u = -u;
                v = -v;
              } else if (b == 1) {
                u = -u;
              } else if (b == 10) {
                v = -v;
              }
            }

            value_0 = { u: u, v, v };
            thisGridData[i][j] = value_0;
          }
          if (dataType == "wave") {
            let value_w = r + g / 100;
            let angle_origin_w = (b / 255) * 360;
            let angle = angle_origin_w % 360;
            let u = 0,
              v = 0;
            if (a > 0) {
              u = -GetUV(angle, "U");
              v = -GetUV(angle, "V");
            }
            value_0 = { u: u, v, v };
            thisGridData[i][j] = value_0;
          }
        }
      }
      let uvData = thisGridData;
      let FeatherMode = "arrow";
      let scale = 0.4;
      if (dataType == "wind") {
        FeatherMode = "Feather";
        scale = 0.2;
      }
      let elLayer1 = windFeatherLayer({
        zIndex: 30,
        startLat: dataRange.startLat,
        endLat: dataRange.endLat + pa.common.range.scale * 1, // 限制超出纬度底部边缘
        startLon: dataRange.startLon,
        endLon: dataRange.endLon,
        scale: scale,
        FeatherMode: FeatherMode,
      });
      elLayer1.addTo(thisLayerL);
      elLayer1.SetData(uvData);
      return;
    }
    if (dataType == "wind") {

      let ParticleSet = {
        zIndex: 200,
        // color: ["rgb(255, 0, 0)"],
        color: ["rgb(255, 255, 255)"],
        velocityScale: 0.005, //步长，流动速度(尽量不变)
        globalAlpha: 0.9, //全局透明度
        particleAge: 30, //粒子生命周期
        particleMultiplier: 600, //密度
        frame_rate: 30, //刷新率
        lineWidth: 2.5, //线宽
        arrow: false,
        particle: false,
        calRegion: calRegion,
        uData: thisUData,
        vData: thisVData,
        range: dataRange,
      };
      if (pa.attribute.showArrow) {
        ParticleSet.arrow = true;
        ParticleSet.particle = false;
      }
      if (pa.attribute.showParticle) {
        ParticleSet.particle = true;
      }
      let elLayer1 = ParticleLayer(ParticleSet);
      // if (thisLayerL.getLayers().length > 1) {
      //   thisLayerL.removeLayer(thisLayerL.getLayers()[0]);
      // }
      elLayer1.addTo(thisLayerL);
      elLayer1._setdata();
    } else if (dataType == "current") {
      let ParticleSet = {
        zIndex: 200,
        color: ["rgb(255, 255, 255)"], //color: ["rgb(255, 81, 0)"],
        velocityScale: 0.12, //步长，流动速度(尽量不变)0.08,
        globalAlpha: 0.95, //全局透明度
        particleAge: 90, //90, //粒子生命周期
        particleMultiplier: 600, //600, //密度
        frame_rate: 35, //刷新率
        lineWidth: 2, //线宽
        arrow: false,
        particle: false,
        calRegion: calRegion,
        uData: thisUData,
        vData: thisVData,
        range: dataRange,
      };
      if (!pa.attribute.showLand) {
        addnosea();
      }
      if (pa.attribute.showArrow) {
        ParticleSet.arrow = true;
        ParticleSet.particle = false;
      }
      if (pa.attribute.showParticle) {
        ParticleSet.particle = true;
      }
      let elLayer1 = ParticleLayer(ParticleSet);
      // if (thisLayerL.getLayers().length > 0) {
      //   thisLayerL.removeLayer(thisLayerL.getLayers()[0]);
      // }
      elLayer1.addTo(thisLayerL);
      elLayer1._setdata();
      addnosea();
    } else if (dataType == "wave") {
      let ParticleSet = {
        zIndex: 200,
        calRegion: calRegion,
        uData: thisUData,
        vData: thisVData,
        range: dataRange,
        // 使用浪的参数修改海浪
        color: ["rgba(255,255,255,1)"],
        velocityScale: 0.005, //步长，流动速度(尽量不变)
        globalAlpha: 0.95, //全局透明度0.8 0.85
        particleAge: 100, //粒子生命周期100 70
        particleMultiplier: 600, //密度1200 1500
        frame_rate: 15, //刷新率
        lineWidth: 8, //线宽
        // type: "waveDir",
        currentMarkPng: null,
        particle: false,
        arrow: false,
      };
      addnosea();
      if (pa.attribute.showArrow) {
        ParticleSet.arrow = true;
        ParticleSet.particle = true;
      }
      if (pa.attribute.showParticle) {
        ParticleSet.particle = true;
      }
      let elLayer1 = ParticleLayer(ParticleSet);
      // if (thisLayerL.getLayers().length > 0) {
      //   thisLayerL.removeLayer(thisLayerL.getLayers()[0]);
      // }
      elLayer1.addTo(thisLayerL);
      elLayer1._setdata();
      // addnosea();
    } else {
      if (dataType == "wave_height") {
        dataType = "wave";
      }
      // if (dataType == "current_speed") {
      //   dataType = "current_speed10";
      // }

      // if(dataType == "temp"){
      //   dataType = "wave";
      // }
      let option = {
        zIndex: 10,
        showLabel: false,
        opacity: 0.9,
        scalarColor: Config.scalarColor[dataType],
        range: dataRange,
        ifInterColors: true,
        numRange: [0, 250],
      };
      if (pa.attribute.showLabel) {
        option.showLabel = true;
      }

      let elLayer1 = ScalarLayer(option);
      if (thisLayerG.getLayers().length > 0) {
        thisLayerG.removeLayer(thisLayerG.getLayers()[0]);
      }

      elLayer1.addTo(thisLayerG);
      elLayer1.setData(thisGridData);
      if (!pa.attribute.showLand) {
        addnosea();
      }

    }
  };
};
export let removeForecastLayer = () => {
  thisLayerG?.clearLayers();
  // removenosea();
};

export let removeForecastLayerL = () => {
  thisLayerL?.clearLayers();
};
let removenosea = () => {
  if (Config.mapObj.map?.hasLayer(Config.AllLayers.tianditu_v_nosea)) {
    Config.mapObj.map?.removeLayer(Config.AllLayers.tianditu_v_nosea);
    Config.mapObj.map?.removeLayer(Config.AllLayers.zj);
  }
};
let addnosea = () => {
  if (!Config.mapObj.map?.hasLayer(Config.AllLayers.tianditu_v_nosea)) {
    Config.AllLayers.tianditu_v_nosea.addTo(Config.mapObj.map);
    Config.AllLayers.zj.addTo(Config.mapObj.map);
  }
};